uniform sampler2D texture;
uniform sampler2D cdf;

void main()
{
  vec4 c = texture2D( texture, gl_TexCoord[0].st );
  // Texture has pre-multiplied alpha - the color does not.
  vec4 color;
  
  color.rgb = gl_Color.rgb * gl_Color.a;
  color.a = gl_Color.a;
  //gl_FragColor = c * color;

  vec4 lookupC = c * color;
  vec2 lookupCoord = vec2(lookupC.r, 0.9);
  vec4 newColor = texture2D(cdf, lookupCoord);
  gl_FragColor = vec4(newColor.r, newColor.r, newColor.r, 1.0);
}



